<%@page import="java.util.Date"%>
<%@page import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<style type="text/css">
.page-footer {
	margin-top: 20px; padding-bottom: 50px; height: 38px; line-height: 38px; border-top: 2px solid #CCCCCC; color: #737573; text-align: right; font-size: 10pt;
}
</style>

<script type="text/javascript">
<!--
	function addCollectMyfavitorKng(obj) {
		var $me = $(obj);
		$.get('knowledge/knowledgeSearch/collectMyfavitorKng', {
			id : '${model.id}'
		}, function(data) {
			isperp.alert('成功添加到我的收藏夹！');
			$me.hide();
		});
	}
//-->
</script>

<div class="nui-info">

	<div id="knowledgeTitle" class="title">${model.title}</div>

	<div class="categoryInfo">
		发布日期：
		<fmt:formatDate value="${model.publish_date}" pattern="yyyy-MM-dd" />
		&nbsp;&nbsp;提交人：${model.creator_name}&nbsp;&nbsp;
		浏览数(${model.read_times})&nbsp;&nbsp;评论数(${commentCount })&nbsp;&nbsp;<a
			id="btnCommentary" class="nui-txt-link"
			href="javascript:addComment();">发表评论</a>

		<c:if test="${isInMyfavitor eq false }">
			&nbsp;&nbsp; <a onclick="addCollectMyfavitorKng(this);"
				id="btnCollect" class="nui-txt-link">收藏 </a>
		</c:if>

	</div>
	<div class="readInfo">
		知识分类：${model.treenode_name_path}&nbsp;&nbsp;关键词：${model.keyword} </a>
	</div>
	<div class="contents">${model.contents}</div>

     
    <h3 style="font-size:14px;font-weight: bold;">相关流程:</h3>
	<div>
		<isperp:processRelation businessKey="${model.id }" readonly="true"
	processKey="knowledgeProcess" projectIdControl="projectId"></isperp:processRelation>
	</div>
     

	<h3 style="font-size:14px;font-weight: bold;">相关附件:</h3>

	<div>
		<isperp:uploader sourceId="${model.id }" id="knowledgeFiles"
			readonly="true"></isperp:uploader>
	</div>
	
	

	<div class="code_comments code_module">

		<h2>
			<span class="right"> <a href="javascript:addComment();">发表评论</a>
				<a id="backToTop"
				href="javascript:$('.frame-main-cont-body').animate({scrollTop:0},200);">回到顶部</a>
			</span> <a name="comments">最新评论<strong>(${commentCount })</strong> </a>
		</h2>
	</div>
	<div class="comments">
		<ul>
			<c:forEach items="${comments}" var="commentary" varStatus="status">
				<li class="row_${(status.index)%2 }">
					<table>
						<tr>
							<td class="portrait"><c:choose>
									<c:when test="${empty commentary.photo }">
										<img src="img/elements/profile/avatar.png">
									</c:when>
									<c:otherwise>
										<img src="${commentary.photo}">
									</c:otherwise>
								</c:choose></td>
							<td class="body">
								<div class="r_title">
									<b>${commentary.commenter_name}</b> 发表于
									<fmt:formatDate value="${commentary.comment_time}"
										pattern="yyyy-MM-dd HH:mm" />

									<div class="r_content TextContent">
										${commentary.content} <br>
									</div>
								</div>
						</tr>
					</table></li>
			</c:forEach>

		</ul>

	</div>


	<div class="page-footer">
		<span>©<%=new Date().getYear() + 1900%> <%=ContextHolder.getConfigByKey("companyName")%></span>
	</div>

</div>
<div id="dialogAddComment" title="发表评论" style="display: none;">
	<form id="formAddComment" method="post"
		action="knowledge/knowledgeComment/addComment" class="full validate">
		<input type="hidden" name="knowledgeId" value="${model.id }" />
		<div style="padding:10px">
			<h3 class="title">评论内容（10-500字）：</h3>
			<div>
				<textarea id="commentContents" name="contents" rows="10"
					class="required" minlength="10" maxlength="800"></textarea>
			</div>
			<br> 请发表与内容相关并且在法律限制范围内的内容
		</div>
	</form>
</div>


<script type="text/javascript">
	//添加评论
	function addComment() {
		$("#dialogAddComment").dialog("open");
	}

	$("#dialogAddComment").dialog({
		autoOpen : false,
		resizable : false,
		width : 440,
		buttons : [ {
			text : "发表",
			"class" : "nui-mainbtn",
			click : function() {

				//判断字数

				isperp.submitForm({
					formId : "formAddComment",
					success : function(data, data2) {
						if (data && data.success == false) {
							isperp.warnAlert(data.data);
						} else {
							window.location.reload();
						}
					}
				});
			}
		}, {
			text : "关闭",
			click : function() {
				$(this).dialog("close");
			}

		} ]
	});
</script>

